begincreaturescript;

variables;

short i,target,choice,whattosay;

body;

beginstate INIT_STATE;
break;

beginstate DEAD_STATE;
break;

beginstate START_STATE; 
	// if I have a target for some reason, go attack it
	if (target_ok()) {
		if (dist_to_char(get_target()) <= 16)
			set_state(3);
			else set_target(ME,-1);
		}
	
	// Look for a target, attack it if visible
	if (select_target(ME,8,0)) {
		do_attack();
		set_state(3);
		}
		
	// Have I been hit? Strike back!
	if (who_hit_me() >= 0) {
		set_target(ME,who_hit_me());
		do_attack();
		set_state(3);
		}

	// if we're in combat and the above didn't give me anything to do, just
	// stop now. Otherwise, game will keep running script, and that eats up CPU time.
	if (am_i_doing_action() == FALSE)
		end_combat_turn();

	whattosay = get_ran(1,0,4);

	if (whattosay == 0)
		text_bubble_on_char(ME,"Er...");
	if (whattosay == 1)
		text_bubble_on_char(ME,"Uhm...");
	if (whattosay == 2)
		text_bubble_on_char(ME,"Pardon me...");
	if (whattosay == 3)
		text_bubble_on_char(ME,"Could I get by?");
	if (whattosay == 4)
		text_bubble_on_char(ME,"Excuse me...");
break;

beginstate 3; // attacking
	if (target_ok() == FALSE)
		set_state(START_STATE);

	whattosay = get_ran(1,0,4);

	if (whattosay == 0)
		text_bubble_on_char(ME,"Er...");
	if (whattosay == 1)
		text_bubble_on_char(ME,"Uhm...");
	if (whattosay == 2)
		text_bubble_on_char(ME,"Pardon me...");
	if (whattosay == 3)
		text_bubble_on_char(ME,"Could I get by?");
	if (whattosay == 4)
		text_bubble_on_char(ME,"Excuse me...");

	do_attack();
break;


beginstate TALKING_STATE;
	print_str("Talking: Annoying Nelson doesn't respond.");
break;